package as3.carcassone {
	import as3.carcassone.model.Model;
	import as3.carcassone.model.PlayerManager;

	import nl.ypmits.Setup;

	import flash.display.Sprite;
	import flash.events.TransformGestureEvent;
	import flash.ui.Multitouch;
	import flash.ui.MultitouchInputMode;

	[SWF(backgroundColor="#444444", frameRate="40", width="1024", height="568")]
	public class Core extends Sprite {
		public function Core()
		{
			Setup.instance.init( this );

			GameConstants.instance.init();

			// FOR TESTING LET'S START WITH THE BASE
			GameConstants.instance.addBaseTiles();
			PlayerManager.instance.addPlayers( 1 );
			Model.instance.createNewGame();
/*
			KeyLogger.instance.stage = Setup.stage;
			KeyLogger.instance.addKeys( new KeyLoggerInput( Keyboard.ENTER, Model.instance.tilepicker.pickRandomTile ) );
			KeyLogger.instance.enable();
*/			
			Multitouch.inputMode = MultitouchInputMode.GESTURE;
			stage.addEventListener( TransformGestureEvent.GESTURE_ZOOM, zoomHandler );
			stage.addEventListener( TransformGestureEvent.GESTURE_ROTATE, rotateHandler );
		}



		private function zoomHandler( e : TransformGestureEvent ) : void
		{
			trace("Core.zoomHandler("+[e.scaleX, e.scaleY]+")");
			Model.instance.gameboard.scaleX = e.scaleX;
			Model.instance.gameboard.scaleY = e.scaleY;
		}



		private function rotateHandler( e : TransformGestureEvent ) : void
		{
			trace("Core.rotateHandler("+[e.rotation]+")");
			Model.instance.gameboard.rotation = e.rotation;
		}
	}
}
